<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Options Structure Reference</title>
    <link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
    <meta charset="utf-8">
    <script src="../../js/jquery.min.js" defer></script>
    <script src="../../js/jazzy.js" defer></script>
    
    <script src="../../js/lunr.min.js" defer></script>
    <script src="../../js/typeahead.jquery.js" defer></script>
    <script src="../../js/jazzy.search.js" defer></script>
  </head>
  <body>

    <a name="//apple_ref/swift/Struct/Options" class="dashAnchor"></a>

    <a title="Options Structure Reference"></a>

    <header class="header">
      <p class="header-col header-col--primary">
        <a class="header-link" href="../../index.html">
          Kitura Docs
        </a>
         (99% documented)
      </p>
    
      <p class="header-col--secondary">
        <form role="search" action="../../search.json">
          <input type="text" placeholder="Search documentation" data-typeahead>
        </form>
      </p>
    
        <p class="header-col header-col--secondary">
          <a class="header-link" href="https://github.com/Kitura/Kitura/">
            <img class="header-icon" src="../../img/gh.png"/>
            View on GitHub
          </a>
        </p>
    
    </header>

    <p class="breadcrumbs">
      <a class="breadcrumb" href="../../index.html">Kitura Reference</a>
      <img class="carat" src="../../img/carat.png" />
      Options Structure Reference
    </p>

    <div class="content-wrapper">
      <nav class="navigation">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../../Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/BodyParser.html">BodyParser</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/BodyParserMultiValue.html">BodyParserMultiValue</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/ContentType.html">ContentType</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/Kitura.html">Kitura</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/Router.html">Router</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/RouterMiddlewareGenerator.html">RouterMiddlewareGenerator</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/RouterRequest.html">RouterRequest</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/RouterResponse.html">RouterResponse</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/StaticFileServer.html">StaticFileServer</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/StaticFileServer/CacheOptions.html">– CacheOptions</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Classes/StaticFileServer/Options.html">– Options</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../../Enums.html">Enumerations</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Enums/JSONPError.html">JSONPError</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Enums/LinkParameter.html">LinkParameter</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Enums/ParsedBody.html">ParsedBody</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Enums/RouterMethod.html">RouterMethod</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../../Extensions.html">Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Extensions/DecodingError.html">DecodingError</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../../Protocols.html">Protocols</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Protocols/ResponseHeadersSetter.html">ResponseHeadersSetter</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Protocols/RouterMiddleware.html">RouterMiddleware</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Protocols/TypeSafeMiddleware.html">TypeSafeMiddleware</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../../Structs.html">Structures</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Structs/AdditionalCookieAttribute.html">AdditionalCookieAttribute</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Structs/CodableHelpers.html">CodableHelpers</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Structs/HTTPVersion.html">HTTPVersion</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Structs/Headers.html">Headers</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Structs/MediaType.html">MediaType</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Structs/MediaType/TopLevelType.html">– TopLevelType</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Structs/Part.html">Part</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Structs/Part/HeaderType.html">– HeaderType</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Structs/SSLConfig.html">SSLConfig</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Structs/SwaggerDocument.html">SwaggerDocument</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../../Typealiases.html">Type Aliases</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Typealiases.html#/s:6Kitura14HTTPStatusCodea">HTTPStatusCode</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Typealiases.html#/s:6Kitura16LifecycleHandlera">LifecycleHandler</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Typealiases.html#/s:6Kitura12RequestErrora">RequestError</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Typealiases.html#/s:6Kitura13RouterHandlera">RouterHandler</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Typealiases.html#/s:6Kitura22RouterParameterHandlera">RouterParameterHandler</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Typealiases.html#/s:6Kitura13ServerOptionsa">ServerOptions</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../../Typealiases.html#/s:6Kitura17WrittenDataFiltera">WrittenDataFilter</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">

        <section class="section">
          <div class="section-content top-matter">
            <h1>Options</h1>
              <div class="declaration">
                <div class="language">
                  
                  <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">Options</span></code></pre>

                </div>
              </div>
            <p>Configuration options for StaticFileServer.</p>

          </div>
        </section>

        <section class="section">
          <div class="section-content">
            <div class="task-group">
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6Kitura16StaticFileServerC7OptionsV18possibleExtensions22serveIndexForDirectory8redirect05cacheE012acceptRanges07defaultI0AESaySSG_S2bAC05CacheE0VSbSSSgtcfc"></a>
                    <a name="//apple_ref/swift/Method/init(possibleExtensions:serveIndexForDirectory:redirect:cacheOptions:acceptRanges:defaultIndex:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:6Kitura16StaticFileServerC7OptionsV18possibleExtensions22serveIndexForDirectory8redirect05cacheE012acceptRanges07defaultI0AESaySSG_S2bAC05CacheE0VSbSSSgtcfc">init(possibleExtensions:<wbr>serveIndexForDirectory:<wbr>redirect:<wbr>cacheOptions:<wbr>acceptRanges:<wbr>defaultIndex:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Initialize an Options instance.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">possibleExtensions</span><span class="p">:</span> <span class="p">[</span><span class="kt">String</span><span class="p">]</span> <span class="o">=</span> <span class="p">[],</span> <span class="nv">serveIndexForDirectory</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span>
     <span class="nv">redirect</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="nv">cacheOptions</span><span class="p">:</span> <span class="kt"><a href="../../Classes/StaticFileServer/CacheOptions.html">CacheOptions</a></span> <span class="o">=</span> <span class="kt"><a href="../../Classes/StaticFileServer/CacheOptions.html">CacheOptions</a></span><span class="p">(),</span> <span class="nv">acceptRanges</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span>
     <span class="n">defaultIndex</span><span class="p">:</span> <span class="kt">String</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>possibleExtensions</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>an array of file extensions to be added
to the file name in case the file was not found. The extensions are 
added in the order they appear in the array, and a new search is 
performed.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>serveIndexForDirectory</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>an indication whether to serve
&ldquo;index.html&rdquo; file the requested path is a directory.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>redirect</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>an indication whether to redirect to trailing
&ldquo;/&rdquo; when the requested path is a directory.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>cacheOptions</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>cache options for StaticFileServer.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>defaultIndex</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A default index, like &ldquo;/index.html&rdquo;, to be served if the
requested path is not found. This is intended to be used by single page applications
that wish to fallback to a default index when a requested path is not found, and where
that path is not a file request. It will be assumed that the default index is reachable
from the root directory configured with the StaticFileServer. Here&rsquo;s a usage example:
<code>swift
let router = Router()
router.all(&quot;/&quot;, middleware: StaticFileServer(defaultIndex: &quot;/index.html&quot;))
</code></p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </section>

      </article>
    </div>
    <section class="footer">
      <p>&copy; 2021 <a class="link" href="" target="_blank" rel="external">IBM &amp; Kitura project authors</a>. All rights reserved. (Last updated: 2021-01-25)</p>
      <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.6</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
    </section>
  </body>
</div>
</html>
